﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MenuList.aspx.cs" Inherits="Admin_MenuList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="<%= ResolveUrl("~/jquery-easyui-1.2.6/themes/"+Skin+"/easyui.css") %>"
        rel="stylesheet" type="text/css" />
    <link href="../jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="../Content/js/sysEasyUI.js" type="text/javascript"></script>
    <script type="text/javascript">
        var selectRow;
        $(function () {
            $('#test').treegrid({
                nowrap: false,
                rownumbers: true,
                animate: true,
                url: '../HanderAjax.ashx?para=getMenuTree',
                collapsible: true,
                idField: 'id',
                treeField: 'MenuName',
                columns: [[
					{ field: 'MenuName', title: '菜单名称', width: 200 },
					{ field: 'MenuIcon', title: '菜单图标', width: 120 },
                    { field: 'MenuUrl', title: '菜单地址', width: 220 },
                    { field: 'CreateTime', title: '创建时间', width: 120 },
                    { field: 'UpdateTime', title: '修改时间', width: 120 },
                    { field: 'Suqence', title: '排序', width: 50 }
				]],
                onBeforeExpand: function (node, param) {

                    //$('#test').treegrid('options').url = '../HanderAjax.ashx?para=getMenuTree&parentid=' + node.id; // change the url                       
                },
                onContextMenu: function (e, row) {
                    selectRow = row;
                    e.preventDefault();
                    $(this).treegrid('unselectAll');
                    $(this).treegrid('select', row.code);
                    $('#mm').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                    });
                },
                onLoadError: function (arguments) {
                    alert("onLoadError" + arguments.statusText);
                }
            });
        });
        function Add() {
            openWindow("EditMenu.aspx?para=add&ParentId="+selectRow.id);
        }
        function Update() {
            openWindow("EditMenu.aspx?para=update&id=" + selectRow.id + "&ParentId=" + selectRow.ParentID);
        }

        function Delete() {
            $.ajax({
                type: "POST",
                async: false,
                url: "../HanderAjax.ashx?para=deleteMenu&id=" + selectRow.id,
                success: function (data) {
                    if (data == "ok") {
                        alert("删除成功");
                        $("#test").treegrid("reload");
                    }
                    else {
                        alert(data);
                    }
                }
            });
        }
    </script>
</head>
<body>
    <table id="test" style="height:600px">
    </table>
    <div id="mm" class="easyui-menu" style="width: 120px;">
        <div onclick="Add()" iconcls="icon-add">
            添加</div>
        <div onclick="Update()" iconcls="icon-save">
            修改</div>
        <div onclick="Delete()" iconcls="icon-cancel">
            删除</div>
    </div>
</body>
</html>
